﻿#region COPYRIGHT
//--------------------------------------------------------------------------------
// <copyright file="State.cs" company="starLiGHT Entertainment Studios">
//    Copyright (c) 2011 
//       Roland Rosenkranz (Glatzemann@email.de)
// </copyright>
// <license>
//   This file is part of starLiGHT.GUI.
//
//   It is released under the Microsoft Public License (Ms-PL).
//
//   You should have received a copy of the Microsoft Public License
//   along with starLiGHT.GUI. If not, see http://sle.codeplex.com/license.
//    
//   ADDITIONAL (commercial) LICENSES for starLiGHT.GUI are available on request.
// </license>
// <version>
// **************[ starLiGHT.Engine SVN ]**********************
// * $Rev::                       $:  Revision of last commit *
// * $Author::                    $:  Author of last commit   *
// * $Date::                      $:  Date of last commit     *
// ************************************************************
// </version>
//--------------------------------------------------------------------------------
#endregion

namespace starLiGHT.GUI
{
    #region Using Statements
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Graphics;
    #endregion

    public class State : SkinElement, IEquatable<State>
    {
        #region Member Variables
        private Layout layout;
        private List<Layer> layers = new List<Layer>();
        private Color? foreColor;
        private Color? backColor;
        #endregion

        public State(Layout layout, string name)
            : base(name)
        {
            this.layout = layout;
        }

        public Layout Layout
        {
            get
            {
                return this.layout;
            }
        }

        public IEnumerable<Layer> Layers
        {
            get
            {
                foreach (Layer layer in this.layers)
                {
                    yield return layer;
                }
            }
        }

        public Color? ForeColor
        {
            get
            {
                return this.foreColor;
            }

            set
            {
                this.foreColor = value;
            }
        }

        public Color? BackColor
        {
            get
            {
                return this.backColor;
            }

            set
            {
                this.backColor = value;
            }
        }

        public void AddLayer(Layer layer)
        {
            if (layer == null)
            {
                throw new ArgumentNullException("layer");
            }

            if (this.layers.Contains(layer))
            {
                ////TODO: implement to overwrite inherited layers
                throw new NotImplementedException();
            }
            else
            {
                this.layers.Add(layer);
            }
        }

        public bool Equals(State other)
        {
            return this.Layout.Equals(other.Layout) && this.Name.Equals(other.Name, StringComparison.InvariantCultureIgnoreCase);
        }
    }
}
